What is the `String.prototype.localeCompare` method in JavaScript?
Description : `localeCompare` compares two strings in the current locale and returns a number indicating their relative order.
Answer :
`String.prototype.localeCompare` compares two strings in the current locale and returns a number indicating whether the calling string comes before, after, or is equal to the compared string.const str1 ='apple';const str2 ='banana';const result = str1.localeCompare(str2);
console.log(result);// -1 (str1 is less than str2)
`Array.prototype.flat` creates a newarraywith all sub-array elements concatenated into it recursively up to a specified depth. It can flatten nested arrays to a specified level.const arr =[1,[2,[3,[4]]]];const flatArr = arr.flat(2);
console.log(flatArr);// [1, 2, 3, [4]]
`Array.prototype.flat` creates a newarraywith all sub-array elements concatenated into it recursively up to a specified depth. It can flatten nested arrays to a specified level.const arr =[1,[2,[3,[4]]]];const flatArr = arr.flat(2);
console.log(flatArr);// [1, 2, 3, [4]]
What is the `String.prototype.bold` method in JavaScript?
`String.prototype.bold` returns a string wrapped inHTML`<b>` tags. Note that this method is deprecated and should not be used in modern applications.const str ='hello';const boldStr = str.bold();
console.log(boldStr);// '<b>hello</b>'
`String.prototype.bold` returns a string wrapped inHTML`<b>` tags. Note that this method is deprecated and should not be used in modern applications.const str ='hello';const boldStr = str.bold();
console.log(boldStr);// '<b>hello</b>'